package com.lyon.custom.core.store;

import cn.hutool.core.util.StrUtil;
import org.springframework.core.env.PropertySource;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author LeeYan9
 * @since 2021-12-02
 */
public class LyonPropertySourceRepository {

    private static Map<String, PropertySource<?>> PROPERTY_SOURCE_MAP = new ConcurrentHashMap<>();


    public static void recordApplicationPropertySource(String dataId, String group, PropertySource<?> propertySource) {
        PROPERTY_SOURCE_MAP.put(buildKey(dataId, group), propertySource);
    }

    public static Map<String, PropertySource<?>> all() {
        return PROPERTY_SOURCE_MAP;
    }

    public static String buildKey(String dataId, String group) {
        return StrUtil.join(";", dataId, group);
    }

}
